package com.fyzk.activity.lottery.jc.football.newJz.data;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.tyjc.lottery.R;

import java.util.List;

/**
 * Created by fanxs11 on 16/5/2.
 *
 * 欧赔、亚盘、大小盘adapter
 */
public class AsiaAdapter extends OuPeiAdapter {


    public AsiaAdapter(Context context, List<JCZQ_EuropeDataRespose> infos){
        this.context = context;
        this.infos = infos;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        JCZQ_EuropeDataRespose info = infos.get(i);
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.jc_ouyaxi_item, null);
            holder.coupany_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_company);
            holder.sheng_pl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_sheng);
            holder.ping_pl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_ping);
            holder.fu_pl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_fu);
            holder.sheng_kl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_sheng2);
            holder.ping_kl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_ping2);
            holder.fu_kl_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_fu2);
            holder.fanHuan_tv = (TextView) view.findViewById(R.id.jc_ouyaxi_item_fanhuan);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.coupany_tv.setText(info.getCname());
        if (type == 0) {//赔率数据

            String sheng_updown = "";
            if (info.getUpoddsupdown() == 0) {//下降
                holder.sheng_kl_tv.setTextColor(context.getResources().getColor(R.color.jczq_analysis_green));
                sheng_updown = "↓";
            } else if (info.getUpoddsupdown() == 2) {//上升
                holder.sheng_kl_tv.setTextColor(context.getResources().getColor(R.color.jczq_analysis_red));
                sheng_updown = "↑";
            } else {
                holder.sheng_kl_tv.setTextColor(context.getResources().getColor(R.color.black));
                sheng_updown = "";
            }

            String fu_updown = "";
            if (info.getDownoddsupdown() == 0) {//下降
                holder.fu_kl_tv.setTextColor(context.getResources().getColor(R.color.jczq_analysis_green));
                fu_updown = "↓";
            } else if (info.getDownoddsupdown() == 2) {//上升
                holder.fu_kl_tv.setTextColor(context.getResources().getColor(R.color.jczq_analysis_red));
                fu_updown = "↑";
            } else {
                holder.fu_kl_tv.setTextColor(context.getResources().getColor(R.color.black));
                fu_updown = "";
            }

            holder.sheng_pl_tv.setText(info.getFirstupodds()+"");
            holder.ping_pl_tv.setText(info.getFirstgoalname()+"");
            holder.ping_pl_tv.setTextSize(10);
            holder.fu_pl_tv.setText(info.getFirstdownodds()+"");
            holder.sheng_kl_tv.setText(info.getUpodds()+""+sheng_updown);
            holder.ping_kl_tv.setText(info.getGoalname()+"");
            holder.ping_kl_tv.setTextSize(10);
            holder.fu_kl_tv.setText(info.getDownodds()+""+fu_updown);
            holder.fanHuan_tv.setVisibility(View.GONE);


            holder.ping_pl_tv.setVisibility(View.VISIBLE);
            holder.ping_kl_tv.setVisibility(View.VISIBLE);

        } else {//凯利指数
            holder.sheng_pl_tv.setText(info.getHomewinRate()+"");
            holder.ping_pl_tv.setVisibility(View.GONE);
            holder.fu_pl_tv.setText(info.getGuestwinRate()+"");
            holder.sheng_kl_tv.setText(info.getClHomewinRate()+"");
            holder.ping_kl_tv.setVisibility(View.GONE);
            holder.fu_kl_tv.setText(info.getClGuestwinRate()+"");
            holder.fanHuan_tv.setText(info.getLossRate()+"%");
            holder.fanHuan_tv.setVisibility(View.VISIBLE);

            holder.sheng_kl_tv.setTextColor(context.getResources().getColor(R.color.black));
            holder.ping_kl_tv.setTextColor(context.getResources().getColor(R.color.black));
            holder.fu_kl_tv.setTextColor(context.getResources().getColor(R.color.black));
        }


        return view;
    }



}
